package day4;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.NettyRuntime;

import java.util.concurrent.TimeUnit;

public class TestEventLoop {
    public static void main(String[] args) {
        EventLoopGroup group = new NioEventLoopGroup();
        System.out.println(NettyRuntime.availableProcessors());

        //执行普通任务
        group.next().submit(() -> {
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("OK");
        });

        //执行定时任务
        group.next().scheduleAtFixedRate(() -> {
            System.out.println("OK");
        }, 0, 1, TimeUnit.SECONDS);


    }
}
